package sdk.pay.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.text.TextUtils;

import sdk.pay.utils.dynamic.PayDownloadUtil;
import sdk.pay.utils.PayLogUtil;
import sdk.pay.utils.PayNetUtil;

/**
 * Created by Steven on 2016/10/12 0012.
 */

public class PayNetworkReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (PayNetUtil.isNetworkAvailable()) {
            String action = intent.getAction();
            PayLogUtil.logFourth("PayNetworkReceiver onReceive action = " + action);
            if (!TextUtils.isEmpty(action) && action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                PayDownloadUtil.getInstance().download(context.getApplicationContext());
            }
        }
    }
}
